package stockblaster.client;

import stockblaster.gen.R;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.TextView;

public class PopUpsViewActivity extends Activity {
	LinearLayout objLayout;
	Button backBut;
//	TextView[] objectives;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.pop_ups_view);
		
		objLayout = (LinearLayout) this.findViewById(R.id.objectiveLayout);
		backBut = (Button) this.findViewById(R.id.button6);
		backBut.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				MethodHelper.switch_activity(PopUpsViewActivity.this,
						HelpActivity.class, false);
			}
		});
		
		//initPopUpsView();
	}
	
	@Override
	public void onBackPressed() {
		MethodHelper.switch_activity(PopUpsViewActivity.this,
				HelpActivity.class, false);
	}
	
	public void onResume() {
		super.onResume();
		objLayout.removeAllViews();
		initPopUpsView();
	}
	
	private void initPopUpsView() {
		int max = CurrentUser.getHelpNum();
		RelativeLayout layout;
		LayoutParams lp;
		int j = 1;
//		objectives = new TextView[max*2];
		
		for (int i = 0; i < max; ++i) {
			// set up the layout so we can position them nicely
			layout = new RelativeLayout(this);
			layout.setId(j);

			// text view for the pop ups text
			final TextView tv = new TextView(this);
			tv.setId(j + 1);
			tv.setText(CurrentUser.getHelp(i));
			if ((i % 2) == 0)
				tv.setTextColor(Color.CYAN);
			else
				tv.setTextColor(Color.WHITE);
			tv.setTextSize(22);
			layout.setPadding(0, 0, 0, 0);
			lp = new LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
					RelativeLayout.LayoutParams.WRAP_CONTENT);
			lp.addRule(RelativeLayout.CENTER_HORIZONTAL);
			layout.addView(tv, lp);

			// this is the divider line
			final View v = new View(this);
			v.setBackgroundColor(Color.WHITE);
			v.setLayoutParams(new LayoutParams(
					LinearLayout.LayoutParams.FILL_PARENT, 1));
			
			objLayout.addView(layout);
			objLayout.addView(v);
		}
	
	}
}
